<template>
<div>
  <h1>添加数据3</h1>
  <p>姓名<input type="text" v-model="form3.name"></p >
  <p>年龄<input type="text" v-model="form3.age"></p >
  <button @click="add_stu">提交</button>
  <table>
    <tr>
      <td>姓名</td>
      <td>年龄</td>
    </tr>
    <tr v-for="i in list3">
      <td>{{i.name}}</td>
      <td>{{i.age}}</td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "Orders",
  data(){
    return{
      list3:[],
      form3:{}
    }
  },
  methods: {
    add_stu() {
      this.axios.post('http://127.0.0.1:5000/list', this.form3)
        .then(i => {
          if (i.data.code === 200) {
            alert("添加成功")
            this.show_stu()
          }
        })
    },
    show_stu() {
      this.axios.get('http://127.0.0.1:5000/list')
        .then(i => {
          this.list3 = i.data.list
        })
    },
  }
}
</script>

<style scoped>

</style>
